home *** CD-ROM | disk | FTP | other *** search
- Path: wormer.fn.net!sysadmin@wormer.fn.net
- From: withheld@keepitpublic.com (Rusty Meathook)
- Newsgroups: comp.lang.c
- Subject: Stylistic Concerns with Header Files
- Date: Sat, 20 Apr 1996 20:11:27 GMT
- Organization: Feist Connections
- Message-ID: <4lb9bl$amo@wormer.fn.net>
- NNTP-Posting-Host: mark312.fn.net
- X-Newsreader: Forte Agent .99b.112
-
- I occasionally create the undesirable situation of having to include
- my header files in a certain order, or having to include one header
- file to include another, and I was wondering how I can circumvent
- that. The most common case is something like this:
-
- /* Untested code; call this "foo.h" */
-
- #ifndef _FOO_H_
- #define _FOO_H_
-
- typedef struct price_tag
- {
- float cost;
- BARCODE code;
- struct price_tag *next;
- } PRICE_INFO;
-
- #endif
-
- /* */
-
- /* Untested code; call this "bar.h" */
-
- #ifndef _BAR_H_
- #define _BAR_H_
-
- typedef struct barcode_tag
- {
- char number;
- } BARCODE;
-
- #endif
-
- /* */
-
- Of course, these are intentionally simple examples, and there are
- obvious ways to solve the problem by merging the two header files.
- Imagine, however, that it is undesirable to merge the header files --
- each of them deals with a different library of functions, and need to
- be kept seperate to maintain modularity.
-
- The obvious problem, now, is that a source file that needs to use
- "foo.h" will have to include "bar.h" prior to including "foo.h", which
- is a nasty situation stylistically. Including another header file
- within a header file is even worse.
-
- My question is: how can you keep the two header files seperate, and
- still get away with not having header file dependancies or inclusion
- orders?
-
-